<!--
 * @Author: 朱自强
 * @Date: 2023-04-20 11:58:35
 * @LastEditors: 朱自强
 * @LastEditTime: 2024-03-13 16:11:49
 * @FilePath: \A-LOT-OF-TEST-VUE3\src\components\Aggrid\AgHeader\AgHeader.vue
 * @Description: 
 * 
 * Copyright (c) 2023 by 朱自强, All Rights Reserved. 
-->
<template>
  <div :id="`ag-render-div-${uuid}`" style="width: 100%">
    <div class="header-main">
      <!-- 图标 -->
      <div class="header-before">
        <!-- 编辑图标 -->
        <n-icon size="14" :component="Edit" v-if="currPrarams.edit" />
      </div>
      <!-- 列名 -->
      <div class="header-name">
        {{ currPrarams.displayName }}
      </div>
      <!-- 其它 -->
      <div class="header-after"></div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import type { Ref } from 'vue'
import type { IHeaderParams } from 'ag-grid-community'
import { watch, ref } from 'vue'
import { Edit } from '@vicons/fa'
import { getUUID } from '@/utils/utils'
// 唯一标识
const uuid: string = getUUID()
// 参数
const currPrarams: Ref<IHeaderParams | any> = ref(null)
// 属性
const props = defineProps({
  // ag默认参数
  params: {
    type: Object,
    default: () => ({})
  }
})
// 监听params
watch(
  () => props.params,
  (newVal: any) => {
    // console.log(`监听渲染表头参数`, newVal)
    currPrarams.value = newVal
  },
  { immediate: true, deep: true }
)
// 向外部暴露方法
defineExpose({})
</script>

<style>
.header-main {
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 图标 */
.header-before {
  padding-right: var(--qc-padding-5);
  padding-top: 3px;
}
/* // 列名 */
.header-name {
  font-family: 'pingFangMedium' !important;
  font-weight: var(--qc-font-weight-600) !important;
  font-size: var(--qc-font-size-14) !important;
}
/* // 其它 */
.header-after {
  /* padding-left: 3px; */
}
</style>
